# _*_ coding:utf-8 _*_
#ATM机的存取款功能
#ATM角色 50000
#用户角色 5000
#1、先登录
#   根据用户登录
#2、菜单界面
#   1、取款
#      用户的账户金额就减少了500
#   2、存款
#      用户的账户金额就增加了500块
#   3、查询
#      用户的账户金额显示
ls={"root":"1234","tom":"1234"}
ls1={"root":"5000","tom":"10000"}
ATM={"atm":"50000"}
def unm(name,passwd):
    user = (name,passwd)
    if user in ls.items():
        return True
    else:
        return False

def unm1(business):
    if business=="exit":
        return "exit"
    elif int(business)==1:
        withdrawal=input("请输入取款金额:")
        if withdrawal=="exit" :
            return "exit"
        if int(withdrawal)<=int(ls1[name]) and int(withdrawal)<=int(ATM["atm"]):
            ls1[name]=int(ls1[name])-int(withdrawal)
            print("取款成功")
            return 4
        else:
            print("你的账户金额不足")
            return 4
    elif int(business)==2:
        withdrawal1=input("请输入要存款的金额:")
        if withdrawal1 == "exit":
            return "exit"
        ls1[name]=int(ls1[name])+int(withdrawal1)
        print("存款成功")
        return 4
    elif int(business)==3:
        print(f"你的账户余额为{ls1[name]}")
        return 4



print("输入exit随时退出")
while True:
    name=input("请输入用户名：")
    if name=="exit":
        print("登出")
        break
    passwd=input("请输入密码：")
    if passwd=="exit":
        print("登出")
        break
    a=unm(name,passwd)
    if a==True:
        print("登录成功")
        while True:
            business = input("取款按1，存款按2，查询余额按3：")
            a=unm1(business)
            if a==4:
                continue
            elif str(a)=="exit":
                print("登出")
                break
        break
    else:
        print("用户名或密码输入错误，请重新输入")
        continue



